package week4.day23;

import java.io.*;

/**
 * @Author fengzihao
 * @Date 2024-05-07 19:35
 */
public class ReadAndReverseAndWriter {
    public static void main(String[] args) throws IOException {
        File sourceFile = new File("a.txt");
        File targetFile = new File("b.txt");
        BufferedReader bufferedReader = new BufferedReader(new FileReader(sourceFile));
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(targetFile,true));
        String str = null;
        while((str = bufferedReader.readLine())!=null){
            str = new StringBuilder(str).reverse().toString();
            bufferedWriter.write(str);
            bufferedWriter.newLine();
            bufferedWriter.flush();
        }
        bufferedReader.close();
        bufferedWriter.close();
    }
}
